<!doctype html>



  


<html class="theme-next muse use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>









<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.1" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="Linux命令," />








  <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=5.1.1" />






<meta name="description" content="&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;Linux du 命令也是查看是有那个空间的，但是与 df 命令不同的是对文件和目录磁盘使用的空间的查看，还是和 df 命令有一写区别的。 1.命令格式1du [选项] [文件] 2.命令功能&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;显示每个文件和目">
<meta name="keywords" content="Linux命令">
<meta property="og:type" content="article">
<meta property="og:title" content="Linux 命令- du">
<meta property="og:url" content="https://hcldirgit.github.io/2017/09/03/2. Linux 命令/36. Linux 命令- du/index.html">
<meta property="og:site_name" content="失落的乐章">
<meta property="og:description" content="&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;Linux du 命令也是查看是有那个空间的，但是与 df 命令不同的是对文件和目录磁盘使用的空间的查看，还是和 df 命令有一写区别的。 1.命令格式1du [选项] [文件] 2.命令功能&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;显示每个文件和目">
<meta property="og:locale" content="zh-Hans">
<meta property="og:updated_time" content="2017-09-01T08:35:25.275Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Linux 命令- du">
<meta name="twitter:description" content="&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;Linux du 命令也是查看是有那个空间的，但是与 df 命令不同的是对文件和目录磁盘使用的空间的查看，还是和 df 命令有一写区别的。 1.命令格式1du [选项] [文件] 2.命令功能&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;显示每个文件和目">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Muse',
    sidebar: {"position":"left","display":"post","offset":12,"offset_float":0,"b2t":false,"scrollpercent":false},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="https://hcldirgit.github.io/2017/09/03/2. Linux 命令/36. Linux 命令- du/"/>





  <title>Linux 命令- du | 失落的乐章</title>
</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  




<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
            (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
          m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
  ga('create', '85*****1', 'auto');
  ga('send', 'pageview');
</script>


  <script type="text/javascript">
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "https://hm.baidu.com/hm.js?87980c**************99ec5e26fb5";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>











  
  
    
  

  <div class="container sidebar-position-left page-post-detail ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">失落的乐章</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle">技术面前，永远都是学生。</p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-message">
          <a href="/message" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-external-link"></i> <br />
            
            留言
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
    <link itemprop="mainEntityOfPage" href="https://hcldirgit.github.io/2017/09/03/2. Linux 命令/36. Linux 命令- du/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="失落的乐章">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/0.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="失落的乐章">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">Linux 命令- du</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-09-03T01:57:34+08:00">
                2017-09-03
              </time>
            

            

            
          </span>

          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    <div class="post-body" itemprop="articleBody">

      
      

      
        <p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Linux du 命令也是查看是有那个空间的，但是与 df 命令不同的是对文件和目录磁盘使用的空间的查看，还是和 df 命令有一写区别的。</p>
<h2 id="1-命令格式"><a href="#1-命令格式" class="headerlink" title="1.命令格式"></a>1.命令格式</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">du [选项] [文件]</div></pre></td></tr></table></figure>
<h2 id="2-命令功能"><a href="#2-命令功能" class="headerlink" title="2.命令功能"></a>2.命令功能</h2><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;显示每个文件和目录的磁盘使用空间。</p>
<h2 id="3-命令参数"><a href="#3-命令参数" class="headerlink" title="3.命令参数"></a>3.命令参数</h2><ul>
<li>-a或-all  显示目录中个别文件的大小。   </li>
<li>-b或-bytes  显示目录或文件大小时，以byte为单位。</li>
<li>-c或–total  除了显示个别目录或文件的大小外，同时也显示所有目录或文件的总和。 </li>
<li>-k或–kilobytes  以KB(1024bytes)为单位输出。</li>
<li>-m或–megabytes  以MB为单位输出。 </li>
<li>-s或–summarize  仅显示总计，只列出最后加总的值。</li>
<li>-h或–human-readable  以K，M，G为单位，提高信息的可读性。</li>
<li>-x或–one-file-xystem  以一开始处理时的文件系统为准，若遇上其它不同的文件系统目录则略过。 </li>
<li>-L&lt;符号链接&gt;或–dereference&lt;符号链接&gt; 显示选项中所指定符号链接的源文件大小。  </li>
<li>-S或–separate-dirs   显示个别目录的大小时，并不含其子目录的大小。 </li>
<li>-X&lt;文件&gt;或–exclude-from=&lt;文件&gt;  在&lt;文件&gt;指定目录或文件。</li>
<li>–exclude=&lt;目录或文件&gt;         略过指定的目录或文件。  </li>
<li>-D或–dereference-args   显示指定符号链接的源文件大小。 </li>
<li>-H或–si  与-h参数相同，但是K，M，G是以1000为换算单位。 </li>
<li>-l或–count-links   重复计算硬件链接的文件。</li>
</ul>
<h2 id="4-使用实例"><a href="#4-使用实例" class="headerlink" title="4.使用实例"></a>4.使用实例</h2><h3 id="实例1：显示目录或者文件所占空间"><a href="#实例1：显示目录或者文件所占空间" class="headerlink" title="实例1：显示目录或者文件所占空间"></a>实例1：显示目录或者文件所占空间</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>命令</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">du</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>输出</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div></pre></td><td class="code"><pre><div class="line">[root@localhost <span class="built_in">test</span>]<span class="comment"># du</span></div><div class="line">608     ./test6</div><div class="line">308     ./test4</div><div class="line">4       ./scf/lib</div><div class="line">4       ./scf/service/deploy/product</div><div class="line">4       ./scf/service/deploy/info</div><div class="line">12      ./scf/service/deploy</div><div class="line">16      ./scf/service</div><div class="line">4       ./scf/doc</div><div class="line">4       ./scf/bin</div><div class="line">32      ./scf</div><div class="line">8       ./test3</div><div class="line">1288    .</div><div class="line">[root@localhost <span class="built_in">test</span>]<span class="comment">#</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>说明</strong></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;只显示当前目录下面的子目录的目录大小和当前目录的总的大小，最下面的 1288 为当前目录的总大小。</p>
<h2 id="实例2：显示指定文件所占空间"><a href="#实例2：显示指定文件所占空间" class="headerlink" title="实例2：显示指定文件所占空间"></a>实例2：显示指定文件所占空间</h2><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>命令</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">du log2012.log</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>输出</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">[root@localhost <span class="built_in">test</span>]<span class="comment"># du log2012.log </span></div><div class="line">300     log2012.log</div><div class="line">[root@localhost <span class="built_in">test</span>]<span class="comment">#</span></div></pre></td></tr></table></figure>
<h3 id="实例3：查看指定目录的所占空间"><a href="#实例3：查看指定目录的所占空间" class="headerlink" title="实例3：查看指定目录的所占空间"></a>实例3：查看指定目录的所占空间</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>命令</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">du scf</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>输出</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div></pre></td><td class="code"><pre><div class="line">[root@localhost <span class="built_in">test</span>]<span class="comment"># du scf</span></div><div class="line">4       scf/lib</div><div class="line">4       scf/service/deploy/product</div><div class="line">4       scf/service/deploy/info</div><div class="line">12      scf/service/deploy</div><div class="line">16      scf/service</div><div class="line">4       scf/doc</div><div class="line">4       scf/bin</div><div class="line">32      scf</div><div class="line">[root@localhost <span class="built_in">test</span>]<span class="comment">#</span></div></pre></td></tr></table></figure>
<h3 id="实例4：显示多个文件所占空间"><a href="#实例4：显示多个文件所占空间" class="headerlink" title="实例4：显示多个文件所占空间"></a>实例4：显示多个文件所占空间</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>命令</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">du log30.tar.gz log31.tar.gz</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>输出</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line">[root@localhost <span class="built_in">test</span>]<span class="comment"># du log30.tar.gz log31.tar.gz </span></div><div class="line">4       log30.tar.gz</div><div class="line">4       log31.tar.gz</div><div class="line">[root@localhost <span class="built_in">test</span>]<span class="comment">#</span></div></pre></td></tr></table></figure>
<h3 id="实例5：只显示总和的大小"><a href="#实例5：只显示总和的大小" class="headerlink" title="实例5：只显示总和的大小"></a>实例5：只显示总和的大小</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>命令</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">du -s</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>输出</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div></pre></td><td class="code"><pre><div class="line">[root@localhost <span class="built_in">test</span>]<span class="comment"># du -s</span></div><div class="line">1288    .</div><div class="line">[root@localhost <span class="built_in">test</span>]<span class="comment"># du -s scf</span></div><div class="line">32      scf</div><div class="line">[root@localhost <span class="built_in">test</span>]<span class="comment"># cd ..</span></div><div class="line">[root@localhost soft]<span class="comment"># du -s test</span></div><div class="line">1288    <span class="built_in">test</span></div><div class="line">[root@localhost soft]<span class="comment">#</span></div></pre></td></tr></table></figure>
<h3 id="实例6：方便阅读的格式显示"><a href="#实例6：方便阅读的格式显示" class="headerlink" title="实例6：方便阅读的格式显示"></a>实例6：方便阅读的格式显示</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>命令</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">du -h <span class="built_in">test</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>输出</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div></pre></td><td class="code"><pre><div class="line">[root@localhost soft]<span class="comment"># du -h test</span></div><div class="line">608K    <span class="built_in">test</span>/test6</div><div class="line">308K    <span class="built_in">test</span>/test4</div><div class="line">4.0K    <span class="built_in">test</span>/scf/lib</div><div class="line">4.0K    <span class="built_in">test</span>/scf/service/deploy/product</div><div class="line">4.0K    <span class="built_in">test</span>/scf/service/deploy/info</div><div class="line">12K     <span class="built_in">test</span>/scf/service/deploy</div><div class="line">16K     <span class="built_in">test</span>/scf/service</div><div class="line">4.0K    <span class="built_in">test</span>/scf/doc</div><div class="line">4.0K    <span class="built_in">test</span>/scf/bin</div><div class="line">32K     <span class="built_in">test</span>/scf</div><div class="line">8.0K    <span class="built_in">test</span>/test3</div><div class="line">1.3M    <span class="built_in">test</span></div><div class="line">[root@localhost soft]<span class="comment">#</span></div></pre></td></tr></table></figure>
<h3 id="实例7：文件和目录都显示"><a href="#实例7：文件和目录都显示" class="headerlink" title="实例7：文件和目录都显示"></a>实例7：文件和目录都显示</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>命令</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">du -ah <span class="built_in">test</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>输出</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div></pre></td><td class="code"><pre><div class="line">[root@localhost soft]<span class="comment"># du -ah test</span></div><div class="line">4.0K    <span class="built_in">test</span>/log31.tar.gz</div><div class="line">4.0K    <span class="built_in">test</span>/test13.tar.gz</div><div class="line">0       <span class="built_in">test</span>/linklog.log</div><div class="line">0       <span class="built_in">test</span>/test6/log2014.log</div><div class="line">300K    <span class="built_in">test</span>/test6/linklog.log</div><div class="line">0       <span class="built_in">test</span>/test6/log2015.log</div><div class="line">4.0K    <span class="built_in">test</span>/test6/log2013.log</div><div class="line">300K    <span class="built_in">test</span>/test6/log2012.log</div><div class="line">0       <span class="built_in">test</span>/test6/log2017.log</div><div class="line">0       <span class="built_in">test</span>/test6/log2016.log</div><div class="line">608K    <span class="built_in">test</span>/test6</div><div class="line">0       <span class="built_in">test</span>/log2015.log</div><div class="line">0       <span class="built_in">test</span>/test4/log2014.log</div><div class="line">4.0K    <span class="built_in">test</span>/test4/log2013.log</div><div class="line">300K    <span class="built_in">test</span>/test4/log2012.log</div><div class="line">308K    <span class="built_in">test</span>/test4</div><div class="line">4.0K    <span class="built_in">test</span>/scf/lib</div><div class="line">4.0K    <span class="built_in">test</span>/scf/service/deploy/product</div><div class="line">4.0K    <span class="built_in">test</span>/scf/service/deploy/info</div><div class="line">12K     <span class="built_in">test</span>/scf/service/deploy</div><div class="line">16K     <span class="built_in">test</span>/scf/service</div><div class="line">4.0K    <span class="built_in">test</span>/scf/doc</div><div class="line">4.0K    <span class="built_in">test</span>/scf/bin</div><div class="line">32K     <span class="built_in">test</span>/scf</div><div class="line">4.0K    <span class="built_in">test</span>/log2013.log</div><div class="line">300K    <span class="built_in">test</span>/log2012.log</div><div class="line">0       <span class="built_in">test</span>/log2017.log</div><div class="line">0       <span class="built_in">test</span>/log2016.log</div><div class="line">4.0K    <span class="built_in">test</span>/log30.tar.gz</div><div class="line">4.0K    <span class="built_in">test</span>/log.tar.bz2</div><div class="line">4.0K    <span class="built_in">test</span>/log.tar.gz</div><div class="line">0       <span class="built_in">test</span>/test3/log2014.log</div><div class="line">4.0K    <span class="built_in">test</span>/test3/log2013.log</div><div class="line">8.0K    <span class="built_in">test</span>/test3</div><div class="line">4.0K    <span class="built_in">test</span>/scf.tar.gz</div><div class="line">1.3M    <span class="built_in">test</span></div><div class="line">[root@localhost soft]<span class="comment">#</span></div></pre></td></tr></table></figure>
<h3 id="实例8：显示几个文件或目录各自占用磁盘空间的大小，还统计它们的综合"><a href="#实例8：显示几个文件或目录各自占用磁盘空间的大小，还统计它们的综合" class="headerlink" title="实例8：显示几个文件或目录各自占用磁盘空间的大小，还统计它们的综合"></a>实例8：显示几个文件或目录各自占用磁盘空间的大小，还统计它们的综合</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>命令</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">du -c log30.tar.gz log31.tar.gz</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>输出</strong></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line">[root@localhost test]# du -c log30.tar.gz log31.tar.gz </div><div class="line">4       log30.tar.gz</div><div class="line">4       log31.tar.gz</div><div class="line">8       总计</div><div class="line">[root@localhost test]#</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>说明</strong></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;加上 -c 选项后，du 不仅先死两个目录各自占用磁盘空间的大小，还在最后一行统计它们的总和。</p>
<h3 id="实例9：按照空间大小排序"><a href="#实例9：按照空间大小排序" class="headerlink" title="实例9：按照空间大小排序"></a>实例9：按照空间大小排序</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>命令</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">du|sort -nr|more</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>输出</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div></pre></td><td class="code"><pre><div class="line">[root@localhost <span class="built_in">test</span>]<span class="comment"># du|sort -nr|more</span></div><div class="line">1288    .</div><div class="line">608     ./test6</div><div class="line">308     ./test4</div><div class="line">32      ./scf</div><div class="line">16      ./scf/service</div><div class="line">12      ./scf/service/deploy</div><div class="line">8       ./test3</div><div class="line">4       ./scf/service/deploy/product</div><div class="line">4       ./scf/service/deploy/info</div><div class="line">4       ./scf/lib</div><div class="line">4       ./scf/doc</div><div class="line">4       ./scf/bin</div><div class="line">[root@localhost <span class="built_in">test</span>]<span class="comment">#</span></div></pre></td></tr></table></figure>
<h3 id="实例10：输出当前目录下各个子目录所使用的空间"><a href="#实例10：输出当前目录下各个子目录所使用的空间" class="headerlink" title="实例10：输出当前目录下各个子目录所使用的空间"></a>实例10：输出当前目录下各个子目录所使用的空间</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>命令</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">du -h --max-depth=1</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>输出</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div></pre></td><td class="code"><pre><div class="line">[root@localhost <span class="built_in">test</span>]<span class="comment"># du -h  --max-depth=1</span></div><div class="line">608K    ./test6</div><div class="line">308K    ./test4</div><div class="line">32K     ./scf</div><div class="line">8.0K    ./test3</div><div class="line">1.3M    .</div><div class="line">[root@localhost <span class="built_in">test</span>]<span class="comment">#</span></div></pre></td></tr></table></figure>
      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        

      
    </div>

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/Linux命令/" rel="tag"># Linux命令</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2017/09/03/2. Linux 命令/27. Linux 命令- chmod/" rel="next" title="Linux 命令- chmod">
                <i class="fa fa-chevron-left"></i> Linux 命令- chmod
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2017/09/03/2. Linux 命令/28. Linux 命令- tar/" rel="prev" title="Linux 命令- tar">
                Linux 命令- tar <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          
  <div class="comments" id="comments">
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="/images/0.png"
               alt="失落的乐章" />
          <p class="site-author-name" itemprop="name">失落的乐章</p>
           
              <p class="site-description motion-element" itemprop="description">失落的乐章的Blog</p>
          
        </div>
        <nav class="site-state motion-element">

          
            <div class="site-state-item site-state-posts">
              <a href="/">
                <span class="site-state-item-count">627</span>
                <span class="site-state-item-name">日志</span>
              </a>
            </div>
          

          

          
            
            
            <div class="site-state-item site-state-tags">
              <a href="/tags/index.html">
                <span class="site-state-item-count">38</span>
                <span class="site-state-item-name">标签</span>
              </a>
            </div>
          

        </nav>

        

        <div class="links-of-author motion-element">
          
            
              <span class="links-of-author-item">
                <a href="https://github.com/hcldirgit" target="_blank" title="GitHub">
                  
                    <i class="fa fa-fw fa-github"></i>
                  
                  GitHub
                </a>
              </span>
            
          
        </div>

        
        

        
        

        


      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#1-命令格式"><span class="nav-number">1.</span> <span class="nav-text">1.命令格式</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2-命令功能"><span class="nav-number">2.</span> <span class="nav-text">2.命令功能</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#3-命令参数"><span class="nav-number">3.</span> <span class="nav-text">3.命令参数</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#4-使用实例"><span class="nav-number">4.</span> <span class="nav-text">4.使用实例</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#实例1：显示目录或者文件所占空间"><span class="nav-number">4.1.</span> <span class="nav-text">实例1：显示目录或者文件所占空间</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#实例2：显示指定文件所占空间"><span class="nav-number">5.</span> <span class="nav-text">实例2：显示指定文件所占空间</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#实例3：查看指定目录的所占空间"><span class="nav-number">5.1.</span> <span class="nav-text">实例3：查看指定目录的所占空间</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#实例4：显示多个文件所占空间"><span class="nav-number">5.2.</span> <span class="nav-text">实例4：显示多个文件所占空间</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#实例5：只显示总和的大小"><span class="nav-number">5.3.</span> <span class="nav-text">实例5：只显示总和的大小</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#实例6：方便阅读的格式显示"><span class="nav-number">5.4.</span> <span class="nav-text">实例6：方便阅读的格式显示</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#实例7：文件和目录都显示"><span class="nav-number">5.5.</span> <span class="nav-text">实例7：文件和目录都显示</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#实例8：显示几个文件或目录各自占用磁盘空间的大小，还统计它们的综合"><span class="nav-number">5.6.</span> <span class="nav-text">实例8：显示几个文件或目录各自占用磁盘空间的大小，还统计它们的综合</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#实例9：按照空间大小排序"><span class="nav-number">5.7.</span> <span class="nav-text">实例9：按照空间大小排序</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#实例10：输出当前目录下各个子目录所使用的空间"><span class="nav-number">5.8.</span> <span class="nav-text">实例10：输出当前目录下各个子目录所使用的空间</span></a></li></ol></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy; 
  <span itemprop="copyrightYear">2017</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">失落的乐章</span>
</div>


<div class="powered-by">
  由 <a class="theme-link" href="https://hexo.io">Hexo</a> 强力驱动
</div>

<div class="theme-info">
  主题 -
  <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next">
    NexT.Muse
  </a>
</div>


        

        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.1"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.1"></script>



  
  

  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.1"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.1"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.1"></script>



  


  




	





  





  





  






  





  

  

  

  

  

  

</body>
</html>
